package com.blue.bluecode;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.util.Linkify;
import android.widget.TextView;


public class TextViewActivity extends Activity {

    private TextView tvTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text_view);

        tvTextView = (TextView) findViewById(R.id.tvTextView);

        /**
         * 1.android:autoLink(none[default],web,email,phone,map,all)
         */
        tvTextView.setAutoLinkMask(Linkify.ALL);

        /**
         * 设置文本
         */
        tvTextView.setText("hello world");

        /**
         *
         * 四个参数对应android:drawableLeft,android:drawableTop,android:drawableRight,android:drawableBottom
         * 作用是在TextView四个边上画图片
         */
//        tvTextView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.ic_launcher),
//                null,null,getResources().getDrawable(R.mipmap.ic_launcher));
        /**
         * 文本改变的Listener
         */
        tvTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }
}
